package com.xmtlxx.web.controller.center.service.impl;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.IdUtil;
import com.xmtlxx.common.tengbo.vo.*;
import com.xmtlxx.oms.domain.*;
import com.xmtlxx.oms.mapper.*;
import com.xmtlxx.tms.domain.bo.*;
import com.xmtlxx.web.controller.center.service.ICommonService;
import com.xmtlxx.web.controller.oms.service.IPropertyLogService;
import com.xmtlxx.web.controller.tms.service.IOrderDtlService;
import com.xmtlxx.web.controller.tms.service.IOrderLogService;
import com.xmtlxx.web.controller.tms.service.IWaybillDtlService;
import com.xmtlxx.web.controller.tms.service.IWaybillLogService;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.xmtlxx.common.core.domain.entity.SysDept;
import com.xmtlxx.common.core.domain.model.LoginUser;
import com.xmtlxx.common.enums.PropertyLogNode;
import com.xmtlxx.common.helper.LoginHelper;
import com.xmtlxx.common.tengbo.PushDatasUtil;
import com.xmtlxx.common.utils.JsonUtils;
import com.xmtlxx.common.utils.StringUtils;
import com.xmtlxx.common.utils.push.domain.PushContent;
import com.xmtlxx.oms.domain.bo.OperatorLogBo;
import com.xmtlxx.oms.domain.bo.PropertyLogBo;
import com.xmtlxx.oms.domain.bo.TaskBo;
import com.xmtlxx.oms.domain.vo.OperatorLogVo;
import com.xmtlxx.oms.domain.vo.TaskVo;
import com.xmtlxx.oms.service.IOperatorLogService;
import com.xmtlxx.system.domain.SysOss;
import com.xmtlxx.system.domain.bo.SysOssBo;
import com.xmtlxx.system.service.ISysDeptService;
import com.xmtlxx.system.service.ISysNoticeService;
import com.xmtlxx.system.service.ISysOssService;
import com.xmtlxx.tms.domain.vo.OrderVo;
import com.xmtlxx.tms.domain.vo.WaybillDtlVo;
import com.xmtlxx.tms.domain.vo.WaybillLogVo;
import com.xmtlxx.tms.domain.vo.WaybillVo;
import com.xmtlxx.tms.mapper.OrderMapper;
import com.xmtlxx.tms.mapper.WaybillMapper;
import com.xmtlxx.wms.domain.*;
import com.xmtlxx.wms.domain.bo.StoreLogBo;
import com.xmtlxx.wms.mapper.DealMapper;
import com.xmtlxx.wms.mapper.HandoverMapper;
import com.xmtlxx.wms.mapper.InventoryLogMapper;
import com.xmtlxx.wms.mapper.StoreMapper;
import com.xmtlxx.wms.service.IStoreLogService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;

@Slf4j
@RequiredArgsConstructor
@Service
public class CommonServiceImpl implements ICommonService {

    private final IOperatorLogService operatorLogService;

    private final IPropertyLogService propertyLogService;

    private final ISysDeptService deptService;

    private final ISysNoticeService sysNoticeService;

    private final IOrderLogService orderLogService;

    private final IWaybillLogService waybillLogService;

    private final IStoreLogService storeLogService;

    private final OrderMapper orderMapper;

    private final IOrderDtlService orderDtlService;

    private final WaybillMapper waybillMapper;

    private final IWaybillDtlService waybillDtlService;

    private final ISysOssService ossService;

    private final BoxDeptMapper boxDeptMapper;

    private final InventoryLogMapper inventoryLogMapper;

    private final PropertyLogMapper propertyLogMapper;

    private final TaskMapper taskMapper;

    private final TaskDtlMapper taskDtlMapper;

    private final HandoverMapper handoverMapper;

    private final DealMapper dealMapper;

    private final StoreMapper storeMapper;

    private final ClassifyMapper classifyMapper;

    private final StagingMapper stagingMapper;

    @Override
    @Transactional(rollbackFor = Exception.class)
    public OperatorLog saveOperatorLog(String objid, String type, String content) {
        OperatorLogBo log = new OperatorLogBo();
        log.setObjid(objid);
        log.setLogTime(new Date());
        if(LoginHelper.checkLoginUser()){
            log.setUserId(LoginHelper.getUserId());
            log.setOperator(LoginHelper.getNickname());
        }else {
            log.setOperator("数据同步");
        }

        log.setLogType(type);
        log.setContent(content);
        return operatorLogService.insertByEntity(log);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void savePropertyLog(String pno,String objid,String name,String buss,String content,Long deptId,String info,String storeId,Long nums,List<SysOss> ossList) {
//        LoginUser loginUser = LoginHelper.getLoginUser();
        PropertyLogBo logBo = new PropertyLogBo();
        logBo.setPno(pno);
        logBo.setName(name);
        logBo.setObjid(objid);
        logBo.setLogTime(new Date());
        logBo.setLogType(buss);
        logBo.setContent(content);
        logBo.setReceiveDept(deptId);
        logBo.setNums(nums != null?nums.toString():"0");
        logBo.setStoreId(storeId);
        logBo.setInfo(info);
        logBo.setDelFlag("0");
//        if(loginUser != null){
//            logBo.setUserId(loginUser.getUserId());
//            logBo.setOperator(loginUser.getNickName());
//            SysDept dept = deptService.selectDeptById(loginUser.getDeptId());
//            if(dept != null){
//                logBo.setNode(PropertyLogNode.getNodeCodeByBuss(dept.getLevel(),buss));
//            }
//        }else{
//            logBo.setOperator("--");
//            logBo.setNode(PropertyLogNode.getNodeCodeByBuss(3l,buss));
//        }

        if(LoginHelper.checkLoginUser()){

            LoginUser loginUser = LoginHelper.getLoginUser();
            logBo.setUserId(loginUser.getUserId());
            logBo.setOperator(loginUser.getNickName());
            SysDept dept = deptService.selectDeptById(loginUser.getDeptId());
            if(dept != null){
                logBo.setNode(PropertyLogNode.getNodeCodeByBuss(dept.getLevel(),buss));
            }
        }else{
            logBo.setOperator("数据同步");
            logBo.setNode(PropertyLogNode.getNodeCodeByBuss(3l,buss));
        }


        PropertyLog enty =  propertyLogService.insertByBo(logBo);

        /**
         * 附件
         */
        if(ossList != null && ossList.size() > 0){
            ossList.forEach(item->{
                SysOss copyOss = new SysOss();
                BeanUtil.copyProperties(item,copyOss,"ossId");
                copyOss.setObjid(enty.getId());
                copyOss.setBuss("propertyLog");
                ossService.addOss(copyOss);
            });
        }


        if(enty != null){
            PropertyLogModelsVo data = new PropertyLogModelsVo();
            data.setApi("proBase");
            data.setData(propertyLogService.selectPropertyLogVoByID(enty.getId()));
            PushDatasUtil.pushPropertyDatas(data);
        }
    }

    @Override
    public void savePropertyLogByOperator(String pno, String objid, String name, String buss, String content, Long deptId, String info, String storeId, Long nums, List<SysOss> ossList, String operator) {
        PropertyLogBo logBo = new PropertyLogBo();
        logBo.setPno(pno);
        logBo.setName(name);
        logBo.setObjid(objid);
        logBo.setLogTime(new Date());
        logBo.setLogType(buss);
        logBo.setContent(content);
        logBo.setReceiveDept(deptId);
        logBo.setNums(nums != null?nums.toString():"0");
        logBo.setStoreId(storeId);
        logBo.setInfo(info);
        logBo.setDelFlag("0");
        if(LoginHelper.checkLoginUser()){

            LoginUser loginUser = LoginHelper.getLoginUser();
            logBo.setUserId(loginUser.getUserId());
            logBo.setOperator(loginUser.getNickName());
            SysDept dept = deptService.selectDeptById(loginUser.getDeptId());
            if(dept != null){
                logBo.setNode(PropertyLogNode.getNodeCodeByBuss(dept.getLevel(),buss));
            }
        }else{
            logBo.setOperator("数据同步");
            logBo.setNode(PropertyLogNode.getNodeCodeByBuss(3l,buss));
        }


        PropertyLog enty =  propertyLogService.insertByBo(logBo);

        /**
         * 附件
         */
        if(ossList != null && ossList.size() > 0){
            ossList.forEach(item->{
                SysOss copyOss = new SysOss();
                BeanUtil.copyProperties(item,copyOss,"ossId");
                copyOss.setObjid(enty.getId());
                copyOss.setBuss("propertyLog");
                ossService.addOss(copyOss);
            });
        }


        if(enty != null){
            PropertyLogModelsVo data = new PropertyLogModelsVo();
            data.setApi("proBase");
            data.setData(propertyLogService.selectPropertyLogVoByID(enty.getId()));
            PushDatasUtil.pushPropertyDatas(data);
        }
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void saveOrderLog(OrderBo bo, String logType) {
        OrderLogBo logBo = new OrderLogBo();
        logBo.setOrderId(bo.getId());
        logBo.setLogTime(new Date());
        logBo.setUserId(LoginHelper.getUserId());
        logBo.setOperator(LoginHelper.getUsername());
        logBo.setLogType(logType);
        logBo.setDelFlag("0");
        logBo.setContent(JsonUtils.toJsonString(bo));
        orderLogService.insertByBo(logBo);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void saveWaybillLog(WaybillBo bo, String logType) {
        WaybillLogBo logBo = new WaybillLogBo();
        logBo.setContent(JsonUtils.toJsonString(bo));
        logBo.setOperator(LoginHelper.getNickname());
        logBo.setOperatorId(LoginHelper.getUserId().toString());
        logBo.setTrackId(bo.getId());
        logBo.setCreateTime(new Date());
        logBo.setType(logType);
        waybillLogService.insertByBo(logBo);
    }

    @Override
    public void saveStoreLog(TaskBo bo) {
        StoreLogBo logBo = new StoreLogBo();
        logBo.setDeptId(bo.getDeptId());
        logBo.setStoreId(bo.getStoreId());
        logBo.setLogTime(new Date());
        if(LoginHelper.checkLoginUser()){
            logBo.setUserId(LoginHelper.getUserId());
            logBo.setOperator(LoginHelper.getUsername());
        }else{
            logBo.setOperator("数据同步");
        }

        logBo.setLogType(bo.getType());
        logBo.setDelFlag("0");
        logBo.setContent(JsonUtils.toJsonString(bo));
        storeLogService.insertByBo(logBo);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void sendSysNotice(String noticeType,List<String> toUsers,Long deptId,String title,String contentInfo,String payload) {
        PushContent pushContent = new PushContent();
        pushContent.setTitle(title);
        pushContent.setPayload(payload);
        pushContent.setClickType("payload");
        pushContent.setContent(contentInfo);
        pushContent.setBody(pushContent.getContent());
        sysNoticeService.sendNotice(noticeType,toUsers,deptId,pushContent,contentInfo);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void orderPush(String id) {
        try {
            OrderVo vo = orderMapper.selectOrderVoByID(id);
            //订单明细
            OrderDtlBo dtlBo = new OrderDtlBo();
            dtlBo.setOrderId(id);
            vo.setItems(orderDtlService.queryList(dtlBo));

            //操作日志
            OperatorLogBo ologBo = new OperatorLogBo();
            ologBo.setObjid(vo.getTaskId());
            ologBo.setLogType("tms");
            List<OperatorLogVo> ologVos = operatorLogService.queryList(ologBo);
            vo.setOperatorLogs(ologVos);

            //订单日志
            OrderLogBo orderLogBo = new OrderLogBo();
            orderLogBo.setOrderId(id);
            vo.setOrderLogs(orderLogService.queryList(orderLogBo));

            WaybillBo waybillBo = new WaybillBo();
            WaybillLogBo waybillLogBo = new WaybillLogBo();
            WaybillDtlBo waybillDtlBo = new WaybillDtlBo();

            //子订单(暂存单时)
            OrderBo bo = new OrderBo();
            bo.setFid(id);
            List<OrderVo> orderItems = orderMapper.selectOrderList(bo);
            if(orderItems != null && orderItems.size() > 0){
                orderItems.forEach(item->{
                    dtlBo.setOrderId(item.getId());
                    item.setItems(orderDtlService.queryList(dtlBo));
                    orderLogBo.setOrderId(item.getId());
                    item.setOrderLogs(orderLogService.queryList(orderLogBo));

                    waybillBo.setOrderId(item.getId());
                    List<WaybillVo> waybillItems = waybillMapper.selectWaybillList(waybillBo);
                    waybillItems.forEach(waybill->{
                        waybillDtlBo.setWaybillId(item.getId());
                        List<WaybillDtlVo> dtls = waybillDtlService.queryList(waybillDtlBo);
                        if(dtls != null && dtls.size() >0){
                            waybill.setItems(dtls);
                        }
                        waybillLogBo.setTrackId(item.getId());
                        List<WaybillLogVo> logItems = waybillLogService.queryList(waybillLogBo);
                        if(logItems != null && logItems.size() > 0){
                            waybill.setLogItems(logItems);
                        }
                    });
                    item.setWayItems(waybillItems);

                    //车架号
                    SysOssBo ossBo = new SysOssBo();
                    ossBo.setObjid(id);
                    ossBo.setBuss("carNumber");
                    item.setCarOss(ossService.selectSysOssList(ossBo));

                    //交接现场
                    ossBo.setBuss("handover");
                    item.setHandoverOss(ossService.selectSysOssList(ossBo));

                    //装车
                    ossBo.setBuss("load");
                    item.setLoadOss(ossService.selectSysOssList(ossBo));

                    //目的地
                    ossBo.setBuss("take");
                    item.setTakeOss(ossService.selectSysOssList(ossBo));

                    //卸车
                    ossBo.setBuss("unload");
                    item.setUnloadOss(ossService.selectSysOssList(ossBo));

                    //其他
                    ossBo.setBuss("other");
                    item.setOtherOss(ossService.selectSysOssList(ossBo));
                });

                vo.setOrderItems(orderItems);
            }

            //运单

            waybillBo.setOrderId(id);
            List<WaybillVo> waybillItems = waybillMapper.selectWaybillList(waybillBo);
            if(waybillItems != null && waybillItems.size() > 0){
                waybillItems.forEach(item->{
                    waybillDtlBo.setWaybillId(item.getId());
                    List<WaybillDtlVo> items = waybillDtlService.queryList(waybillDtlBo);
                    if(items != null && items.size() >0){
                        item.setItems(items);
                    }

                    waybillLogBo.setTrackId(item.getId());

                    List<WaybillLogVo> logItems = waybillLogService.queryList(waybillLogBo);
                    if(logItems != null && logItems.size() > 0){
                        item.setLogItems(logItems);
                    }
                });
                vo.setWayItems(waybillItems);
            }

            //车架号
            SysOssBo ossBo = new SysOssBo();
            ossBo.setObjid(id);
            ossBo.setBuss("carNumber");
            vo.setCarOss(ossService.selectSysOssList(ossBo));

            //交接现场
            ossBo.setBuss("handover");
            vo.setHandoverOss(ossService.selectSysOssList(ossBo));

            //装车
            ossBo.setBuss("load");
            vo.setLoadOss(ossService.selectSysOssList(ossBo));

            //目的地
            ossBo.setBuss("take");
            vo.setTakeOss(ossService.selectSysOssList(ossBo));

            //卸车
            ossBo.setBuss("unload");
            vo.setUnloadOss(ossService.selectSysOssList(ossBo));

            //其他
            ossBo.setBuss("other");
            vo.setOtherOss(ossService.selectSysOssList(ossBo));

            OrderModelsVo data = new OrderModelsVo();
            data.setApi("logistics");
            data.setData(vo);
            log.info("PushTMSOrderDatas Datas = >{}", JsonUtils.toJsonString(data));
            PushDatasUtil.addTask("logistics",data);
        }catch (Exception e){
            e.printStackTrace();
            log.error("PushTMSOrderDatas Error = >{}",e.getMessage());
        }
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void taskPush(String id,String action) {
        TaskVo task = taskMapper.selectTaskVoByID(id);
        List<TaskDtl> dtls = taskDtlMapper.selectList(new LambdaQueryWrapper<TaskDtl>().eq(TaskDtl::getTaskId,task.getId()).eq(TaskDtl::getDelFlag,"2"));
        List<OperatorLog> oplogs = new ArrayList<>();

        switch (action){
            case "0":
                oplogs.add(this.saveOperatorLog(id,"oms","恢复订单"));
                break;
            case "1":
                oplogs.add(this.saveOperatorLog(id,"oms","撤销订单"));
                break;
        }

        if(task.getSource().equals("0") && StringUtils.isNotEmpty(task.getType())){
            TaskVo vo = taskMapper.selectTaskVoByID(task.getId());
            switch (task.getType()){
                case "0":
                    InTaskDatasVo data = BeanUtil.toBean(vo,InTaskDatasVo.class);
                    List<InTaskDatasDtlVo> items = dtls.stream().map(item->{
                        InTaskDatasDtlVo dvo = BeanUtil.copyProperties(item,InTaskDatasDtlVo.class);
                        return dvo;
                    }).collect(Collectors.toList());
                    data.setItems(items);
                    data.setLogs(oplogs);
                    PushDatasUtil.pushInTaskDatas(data);
                    break;
                case "1":
                    OutTaskDatasVo outData = BeanUtil.toBean(vo,OutTaskDatasVo.class);
                    List<OutTaskDatasDtlVo> outItems = dtls.stream().map(item->{
                        OutTaskDatasDtlVo dvo = BeanUtil.copyProperties(item,OutTaskDatasDtlVo.class);
                        return dvo;
                    }).collect(Collectors.toList());
                    outData.setItems(outItems);
                    outData.setLogs(oplogs);
                    PushDatasUtil.pushOutTaskDatas(outData);
                    break;
                case "3"://"创建调用申请"

                    break;
                default:
                    break;
            }
        }
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void saveBoxDept(Box box) {
        BoxDept boxDept = new BoxDept();
        boxDept.setId(IdUtil.simpleUUID());
        boxDept.setBoxId(box.getId());
        boxDept.setBoxNo(box.getBoxNo());
        boxDept.setBoxDept(box.getDeptId());
        boxDept.setStatus("1");
        boxDept.setDelFlag("0");
        boxDeptMapper.insert(boxDept);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void saveInventoryLog(Inventory inventory, Long befores, Long nums, Long afters, String objid, String type) {
        InventoryLog log = new InventoryLog();
        log.setId(IdUtil.simpleUUID());
        log.setStockId(inventory.getId());
        log.setStoreId(inventory.getStoreId());
        log.setDeptId(inventory.getDeptId());
        log.setBefores(befores);
        log.setNums(nums);
        log.setAfters(afters);
        log.setType(type);
        log.setReferId(objid);
        if(LoginHelper.checkLoginUser()){
            log.setOperator(LoginHelper.getUsername());
        }else{
            log.setOperator("数据同步");
        }

        log.setStatus("0");
        log.setDelFlag("0");
        inventoryLogMapper.insert(log);
    }

    @Override
    public void autographPush(String handoverId) {
        Handover handover = handoverMapper.selectById(handoverId);
        if(handover != null && StringUtils.isNotEmpty(handover.getObjid())){
            TaskVo task = taskMapper.selectTaskVoByID(handover.getObjid());
            switch (task.getType()){
                case "0":
                    if(handover.getType().equals("0")){

                        SignPicsVo picsVo1 = new SignPicsVo();
                        picsVo1.setTaskNo(task.getTaskNo());
                        picsVo1.setSignImage(handover.getSigns());//移送人
                        picsVo1.setOperater("0");
                        picsVo1.setSignTime(handover.getHandTime());
                        PushDatasUtil.pushHandoverSignsDatas(picsVo1);

                        SignPicsVo picsVo2 = new SignPicsVo();
                        picsVo2.setTaskNo(task.getTaskNo());
                        picsVo2.setSignImage(handover.getHandPics());//取件人
                        picsVo2.setOperater("1");
                        picsVo2.setSignTime(handover.getHandTime());
                        PushDatasUtil.pushHandoverSignsDatas(picsVo2);
                    }
                    else if(handover.getType().equals("1")){

                        /**
                         * 自行配送
                         */
                        if(task.getDelivery().equals("1")){
                            SignPicsVo picsVo3 = new SignPicsVo();
                            picsVo3.setTaskNo(task.getTaskNo());
                            picsVo3.setSignImage(handover.getSigns());//移送人
                            picsVo3.setOperater("0");
                            picsVo3.setSignTime(handover.getHandTime());
                            PushDatasUtil.pushHandoverSignsDatas(picsVo3);
                        }

                        SignPicsVo picsVo1 = new SignPicsVo();
                        picsVo1.setTaskNo(task.getTaskNo());
                        picsVo1.setSignImage(handover.getCounterpartSign());//中心受理人
                        picsVo1.setSignTime(handover.getHandTime());
                        picsVo1.setOperater("2");

                        PushDatasUtil.pushHandoverSignsDatas(picsVo1);

                        SignPicsVo picsVo2 = new SignPicsVo();
                        picsVo2.setTaskNo(task.getTaskNo());
                        picsVo2.setSignImage(handover.getCheckSign());//中心保管人
                        picsVo2.setSignTime(handover.getHandTime());
                        picsVo2.setOperater("3");

                        if(StringUtils.isNotEmpty(handover.getSignsFile())){
                            SignPicsVo picsVo4 = new SignPicsVo();
                            picsVo4.setTaskNo(task.getTaskNo());
                            picsVo4.setSignImage(handover.getSignsFile());//交接原件
                            picsVo4.setOperater("6");
                        }

                        PushDatasUtil.pushHandoverSignsDatas(picsVo2);
                    }

                    break;
                default:

                    if(handover.getType().equals("0")){
                        SignPicsVo picsVo1 = new SignPicsVo();
                        picsVo1.setTaskNo(task.getTaskNo());
                        picsVo1.setSignImage(handover.getCounterpartSign());//中心受理人
                        picsVo1.setOperater("2");
                        picsVo1.setSignTime(handover.getHandTime());

                        PushDatasUtil.pushHandoverSignsDatas(picsVo1);

                        SignPicsVo picsVo2 = new SignPicsVo();
                        picsVo2.setTaskNo(task.getTaskNo());
                        picsVo2.setSignImage(handover.getCheckSign());//中心保管人
                        picsVo2.setOperater("3");
                        picsVo2.setSignTime(handover.getHandTime());

                        PushDatasUtil.pushHandoverSignsDatas(picsVo2);

                        SignPicsVo picsVo3 = new SignPicsVo();
                        picsVo3.setTaskNo(task.getTaskNo());
                        picsVo3.setSignImage(handover.getHandPics());//送件人
                        picsVo3.setOperater("4");
                        picsVo3.setSignTime(handover.getHandTime());

                        PushDatasUtil.pushHandoverSignsDatas(picsVo3);


                    }
                    else if(handover.getType().equals("1")){

                        /**
                         * 自行配送
                         */
                        if(task.getDelivery().equals("1")){
                            SignPicsVo picsVo2 = new SignPicsVo();
                            picsVo2.setTaskNo(task.getTaskNo());
                            picsVo2.setSignImage(handover.getCounterpartSign());//中心受理人
                            picsVo2.setOperater("2");
                            picsVo2.setSignTime(handover.getHandTime());

                            PushDatasUtil.pushHandoverSignsDatas(picsVo2);

                            SignPicsVo picsVo3 = new SignPicsVo();
                            picsVo3.setTaskNo(task.getTaskNo());
                            picsVo3.setSignImage(handover.getCheckSign());//中心保管人
                            picsVo3.setOperater("3");
                            picsVo3.setSignTime(handover.getHandTime());

                            PushDatasUtil.pushHandoverSignsDatas(picsVo3);
                        }

                        if(StringUtils.isNotEmpty(handover.getSignsFile())){
                            SignPicsVo picsVo4 = new SignPicsVo();
                            picsVo4.setTaskNo(task.getTaskNo());
                            picsVo4.setSignImage(handover.getSignsFile());//交接原件
                            picsVo4.setOperater("6");
                        }

                        SignPicsVo picsVo1 = new SignPicsVo();
                        picsVo1.setTaskNo(task.getTaskNo());
                        picsVo1.setSignImage(handover.getSigns());//单位签收人
                        picsVo1.setOperater("5");
                        picsVo1.setSignTime(handover.getHandTime());

                        PushDatasUtil.pushHandoverSignsDatas(picsVo1);
                    }

                    break;
            }
        }
    }

    @Override
    public void dealPush(String dealId) {
        RegisterInfoVo vo = new RegisterInfoVo();
        Deal deal = dealMapper.selectById(dealId);
        vo.setDealId(dealId);
        if(StringUtils.isNotEmpty(deal.getRegisterInfo())){
            vo = JSONObject.parseObject(deal.getRegisterInfo(),RegisterInfoVo.class);
            vo.setProNo(deal.getDealNo());
            vo.setCreateTime(deal.getCreateTime());
            vo.setUpdateTime(deal.getUpdateTime());
            vo.setDelFlag(deal.getDelFlag());
            PushDatasUtil.pushDealSignsDatas(vo);
        }
    }

    @Override
    public Boolean StagingDelPush(Staging staging) {

        StagingDatasVo data = new StagingDatasVo();

        SysOssBo ossBo = new SysOssBo();
        ossBo.setBuss("staging");
        ossBo.setObjid(staging.getId());
        List<SysOss> oss = ossService.selectSysOssList(ossBo);

        BeanUtil.copyProperties(staging,data);
        data.setWpbh(staging.getPno());
        data.setProname(staging.getName());

        if(staging.getDeptId() != null){
            SysDept dept = deptService.selectDeptById(staging.getDeptId());
            data.setDeptNo(dept.getDeptCode());
            data.setDeptName(dept.getDeptName());
            data.setUndertaker(dept.getDeptCode());
        }

        if(staging.getTransferDept() != null){
            SysDept dept = deptService.selectDeptById(staging.getTransferDept());
            data.setBelongofficeid(dept.getDeptCode());
        }

        if(staging.getOfficeId() != null){
            SysDept dept = deptService.selectDeptById(staging.getOfficeId());
            data.setOfficeid(dept.getDeptCode());
        }
        if(StringUtils.isNotEmpty(staging.getStoreId())){
            Store store = storeMapper.selectById(staging.getStoreId());
            data.setCustodianplace(store.getName());
        }
        data.setPronum(staging.getNums());
        data.setReceiveNums(staging.getReceiveNums());
        data.setUnit(staging.getUnit());

        if(StringUtils.isNotEmpty(staging.getClassifyId())){
            Classify classify = classifyMapper.selectById(staging.getClassifyId());
            data.setProcategory(classify.getClassifyNo());
        }

        if(StringUtils.isNotEmpty(staging.getSecondClassifyId())){
            Classify classify = classifyMapper.selectById(staging.getSecondClassifyId());
            data.setSeccategory(classify.getClassifyNo());
        }

        if(StringUtils.isNotEmpty(staging.getThirdClassifyId())){
            Classify classify = classifyMapper.selectById(staging.getThirdClassifyId());
            data.setThirdcategory(classify.getClassifyNo());
        }

        data.setType(staging.getType());
        data.setRegisterTime(staging.getRegisterTime());
        data.setRemark(staging.getRemark());
        data.setRegisterer(staging.getRegisterer() == null ? "" :staging.getRegisterer());
        data.setFeature(staging.getFeature());
        data.setCreatedate(staging.getCreateTime());
        data.setUpdatedate(staging.getUpdateTime());
        data.setPersonname(staging.getRegisterer() == null ? "" :staging.getRegisterer());
        data.setOss(oss);
        data.setDelflag(2);
        PropertyLogBo logBo = new PropertyLogBo();
        logBo.setPno(staging.getPno());
        data.setLogs(propertyLogMapper.selectPropertyLogList(logBo));

        boolean flag = stagingMapper.deleteVoById(staging.getId());
        if (flag){
            PushDatasUtil.pushStagingDatas(data);
        }
        return flag;
    }
}
